*******************************************************************
*                                                                 *
* Who Identifies As An Environmental Migrant?                     *
*                                                                 *
* Quynh Nguyen, Gabriele Spilker, Vally Koubi, and Tobias Böhmelt * 
*                                                                 *
* This Version: October 18, 2023                                  *
*                                                                 *
*******************************************************************

**********************
* Analysis - Table 1 *
**********************

use "Final Data Plos One.dta", clear

eststo clear
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 

***********************
* Analysis - Figure 1 *
***********************

tab exposure_n, gen(events)

logit motive_dum_new events2 events3 c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish
logit motive_dum_new events2 events3 c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish
logit motive_dum_new events2 events3 c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish

use "Substantive Quantities.dta", clear

twoway (scatter var2 var7 if var6=="Model 1") (rcap var4 var5 var7 if var6=="Model 1", msize(zero)) (scatter var2 var7 if var6=="Model 2") (rcap var4 var5 var7 if var6=="Model 2", msize(zero)) (scatter var2 var7 if var6=="Model 3") (rcap var4 var5 var7 if var6=="Model 3", msize(zero)), scheme(538w) xline(0, lpattern(solid) lcol(black)) legend(off)

**********************
* Analysis - Table 2 *
**********************

use "Final Data Plos One.dta", clear

eststo clear
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 

***********************
* Analysis - Figure 2 *
***********************

tab exposure_n, gen(events)

logit disaster_yn events2 events3 c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish
logit disaster_yn events2 events3 c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish
logit disaster_yn events2 events3 c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
margins, dydx(events2) at(events3=(0)) atmean vsquish
margins, dydx(events3) at(events2=(0)) atmean vsquish

use "Substantive Quantities2.dta", clear

twoway (scatter var2 var7 if var6=="Model 4") (rcap var4 var5 var7 if var6=="Model 4", msize(zero)) (scatter var2 var7 if var6=="Model 5") (rcap var4 var5 var7 if var6=="Model 5", msize(zero)) (scatter var2 var7 if var6=="Model 6") (rcap var4 var5 var7 if var6=="Model 6", msize(zero)), scheme(538w) xline(0, lpattern(solid) lcol(black)) legend(off)

***********************
* Analysis - Figure 3 *
***********************

use "Final Data Plos One.dta", clear

tab exposure_n, gen(events)
gen age2=age*age

estsimp logit motive_dum_new events2 events3 age age2 female income education property ln_dist abs_spei water_depth, robust
plotfds, discrete(female property) continuous(age age2 income education ln_dist abs_spei water_depth) sortorder(age age2 female income education property ln_dist abs_spei water_depth) changexcont(min max)


*************************************
* Supporting Information - Table S1 *
*************************************

use "Final Data Plos One.dta", clear

bysort ccode: outreg2 using descriptives.doc ,replace sum(log) eqkeep(N mean sd min max) keep(motive_dum_new exposure_n disaster_yn age female income education property ln_dist abs_spei water_depth ethnicity agrozone social_before climchange)

*************************************
* Supporting Information - Table S2 *
*************************************

eststo clear
eststo: logit motive_dum_new i.exposure_new c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit motive_dum_new i.exposure_new c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit motive_dum_new i.exposure_new c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 

*************************************
* Supporting Information - Table S3 *
*************************************

eststo clear
eststo: logit disaster_yn i.exposure_new c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit disaster_yn i.exposure_new c.age##c.age female income education i.ethnicity i.property ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit disaster_yn i.exposure_new c.age##c.age female income education i.property ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 

*************************************
* Supporting Information - Table S4 *
*************************************

eststo clear
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.ethnicity i.property i.social_before climchange ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.ethnicity i.property i.social_before climchange ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit motive_dum_new i.exposure_n c.age##c.age female income education i.property i.social_before climchange ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 

*************************************
* Supporting Information - Table S5 *
*************************************

eststo clear
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.ethnicity i.property i.social_before climchange ln_dist abs_spei water_depth i.agrozone if ccode==1, robust
estimates store reg1
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.ethnicity i.property i.social_before climchange ln_dist abs_spei water_depth i.agrozone if ccode==2, robust
estimates store reg2
eststo: logit disaster_yn i.exposure_n c.age##c.age female income education i.property i.social_before climchange ln_dist abs_spei water_depth, robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label 